home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libs / info / error.c < prev    next >
C/C++ Source or Header  |  1996-11-15  |  3KB  |  122 lines

  1. /* error.c -- Handle info errors. */
  2.  
  3. /* This file is part of GNU Info, a program for reading online documentation
  4.    stored in Info format.
  5.  
  6.    Copyright (C) 1993 Free Software Foundation, Inc.
  7.  
  8.    This program is free software; you can redistribute it and/or modify
  9.    it under the terms of the GNU General Public License as published by
  10.    the Free Software Foundation; either version 2, or (at your option)
  11.    any later version.
  12.  
  13.    This program is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with this program; if not, write to the Free Software
  20.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21.  
  22.    Written by Brian Fox (bfox@ai.mit.edu). */
  23.  
  24. /* Changed by Klaus Gebhardt -- May 1994 */
  25.  
  26. #include "info.h"
  27. #include "dribble.h"
  28. #include "terminal.h"
  29. #include "getopt.h"
  30.  
  31. /* The version numbers of this version of Info. */
  32. int info_major_version = 2;
  33. int info_minor_version = 14;
  34. int info_patch_level = 1;
  35.  
  36. /* When non-zero, the Info window system has been initialized. */
  37. int info_windows_initialized_p = 0;
  38.  
  39. /* Return a string describing the current version of Info. */
  40. char *
  41. version_string ()
  42. {
  43.   static char *vstring = (char *)NULL;
  44.  
  45.   if (!vstring)
  46.     {
  47.       vstring = (char *)xmalloc (50);
  48.  
  49.       sprintf (vstring, "%d.%d", info_major_version, info_minor_version);
  50.       if (info_patch_level)
  51.     sprintf (vstring + strlen (vstring), "-p%d", info_patch_level);
  52.  
  53. #if defined (EMX)
  54.       sprintf (vstring + strlen (vstring), " for OS/2 2.x and Warp");
  55. #endif
  56.  
  57.     }
  58.   return (vstring);
  59. }
  60.  
  61. /* **************************************************************** */
  62. /*                                    */
  63. /*           Error Handling for Info                */
  64. /*                                    */
  65. /* **************************************************************** */
  66.  
  67. #if defined (EMX)
  68. char *program_name;
  69. #else
  70. static char *program_name = (char *)NULL;
  71. #endif
  72.  
  73. /* Non-zero if an error has been signalled. */
  74. int info_error_was_printed = 0;
  75.  
  76. /* Non-zero means ring terminal bell on errors. */
  77. int info_error_rings_bell_p = 1;
  78.  
  79. /* Print FORMAT with ARG1 and ARG2.  If the window system was initialized,
  80.    then the message is printed in the echo area.  Otherwise, a message is
  81.    output to stderr. */
  82. void
  83. info_error (format, arg1, arg2)
  84.      char *format;
  85.      void *arg1, *arg2;
  86. {
  87.   info_error_was_printed = 1;
  88.  
  89.   if (!info_windows_initialized_p || display_inhibited
  90.       || external_info_search_P)
  91.     {
  92. #if defined (EMX)
  93.       fprintf (stderr, "GNU-Info (%s): ", program_name);
  94. #else
  95.       fprintf (stderr, "%s: ", program_name);
  96. #endif
  97.       fprintf (stderr, format, arg1, arg2);
  98.       fprintf (stderr, "\n");
  99.       fflush (stderr);
  100.     }
  101.   else
  102.     {
  103.       if (!echo_area_is_active)
  104.     {
  105.       if (info_error_rings_bell_p)
  106.         terminal_ring_bell ();
  107.       window_message_in_echo_area (format, arg1, arg2);
  108.     }
  109.       else
  110.     {
  111.       NODE *temp;
  112.  
  113.       temp = build_message_node (format, arg1, arg2);
  114.       if (info_error_rings_bell_p)
  115.         terminal_ring_bell ();
  116.       inform_in_echo_area (temp->contents);
  117.       free (temp->contents);
  118.       free (temp);
  119.     }
  120.     }
  121. }
  122.